import { fileURLToPath, URL } from 'node:url'
const { name } = require('../package.json')
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  publicPath: '/subapp/sub-ai',
  // base: "./",
  // plugins: [
  //   vue(),
  // ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  chainWebpack: config => config.resolve.symlinks(false),
  configureWebpack: {
    output: {
      // 把子应用打包成 umd 库格式
      library: `${name}-[name]`,
      libraryTarget: 'umd',
      jsonpFunction: `webpackJsonp_${name}`
    }
  },
  server: {
    port: 3336,
    headers: {
      'Access-Control-Allow-Origin': '*'
    }
  }
})
